#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPainter>
#include <QTimer>
#include <QMouseEvent>
#include <vector>
#include <QPushButton>
#include <QLabel>

const int rows = 100;
const int cols = 100;
static int cellSize = 5;

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow() override;
    void setCellSize(int newSize);

protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void toggleCell(const QPoint &point);
private slots:
    void nextGeneration();
    void startGame();
    void pauseGame();
    void resetGame();

private:
    Ui::MainWindow *ui;
    QTimer *timer;
    std::vector<std::vector<bool>> cells{rows, std::vector<bool>(cols, false)};
    int generationCount;
    bool isDragging = false;
    int countNeighbors(int row, int col) const;

};
#endif // MAINWINDOW_H
